<?php
include(getabspath("include/packing_lists_settings.php"));

function DisplayMasterTableInfo_packing_lists($params)
{
	$detailtable=$params["detailtable"];
	$keys=$params["keys"];
	global $conn,$strTableName;
	$xt = new Xtempl();
	
	$oldTableName=$strTableName;
	$strTableName="packing_lists";

//$strSQL = "SELECT  id,  place,  shipment_date,  buyer_id,  name,  order_no,  consignee_id,  shipment_pack_details,  marks,  ref_id,  \"\" AS buyer_address,  \"\" AS consignee_address  FROM packing_lists  ";

$sqlHead="SELECT id,  place,  shipment_date,  buyer_id,  name,  order_no,  consignee_id,  shipment_pack_details,  marks,  ref_id,  \"\" AS buyer_address,  \"\" AS consignee_address";
$sqlFrom="FROM packing_lists";
$sqlWhere="";
$sqlTail="";

$where="";

if($detailtable=="packing_list_items")
{
		$where.= GetFullFieldName("id")."=".make_db_value("id",$keys[1-1]);
}
if(!$where)
{
	$strTableName=$oldTableName;
	return;
}
	$str = SecuritySQL("Export");
	if(strlen($str))
		$where.=" and ".$str;
	
	$strWhere=whereAdd($sqlWhere,$where);
	if(strlen($strWhere))
		$strWhere=" where ".$strWhere." ";
	$strSQL= $sqlHead.' '.$sqlFrom.$strWhere.$sqlTail;

//	$strSQL=AddWhere($strSQL,$where);

	LogInfo($strSQL);
	$rs=db_query($strSQL,$conn);
	$data=db_fetch_array($rs);
	if(!$data)
	{
		$strTableName=$oldTableName;
		return;
	}
	$keylink="";
	$keylink.="&key1=".htmlspecialchars(rawurlencode(@$data["id"]));
	


//	id - 
			$value="";
				$value = ProcessLargeText(GetData($data,"id", ""),"field=id".$keylink,"",MODE_PRINT);
			$xt->assign("id_mastervalue",$value);

//	place - 
			$value="";
				$value=DisplayLookupWizard("place",$data["place"],$data,$keylink,MODE_PRINT);
			$xt->assign("place_mastervalue",$value);

//	shipment_date - Short Date
			$value="";
				$value = ProcessLargeText(GetData($data,"shipment_date", "Short Date"),"field=shipment%5Fdate".$keylink,"",MODE_PRINT);
			$xt->assign("shipment_date_mastervalue",$value);

//	buyer_id - 
			$value="";
				$value=DisplayLookupWizard("buyer_id",$data["buyer_id"],$data,$keylink,MODE_PRINT);
			$xt->assign("buyer_id_mastervalue",$value);

//	name - 
			$value="";
				$value = ProcessLargeText(GetData($data,"name", ""),"field=name".$keylink,"",MODE_PRINT);
			$xt->assign("name_mastervalue",$value);

//	order_no - 
			$value="";
				$value = ProcessLargeText(GetData($data,"order_no", ""),"field=order%5Fno".$keylink,"",MODE_PRINT);
			$xt->assign("order_no_mastervalue",$value);

//	consignee_id - 
			$value="";
				$value=DisplayLookupWizard("consignee_id",$data["consignee_id"],$data,$keylink,MODE_PRINT);
			$xt->assign("consignee_id_mastervalue",$value);

//	shipment_pack_details - 
			$value="";
				$value = ProcessLargeText(GetData($data,"shipment_pack_details", ""),"field=shipment%5Fpack%5Fdetails".$keylink,"",MODE_PRINT);
			$xt->assign("shipment_pack_details_mastervalue",$value);

//	marks - 
			$value="";
				$value = ProcessLargeText(GetData($data,"marks", ""),"field=marks".$keylink,"",MODE_PRINT);
			$xt->assign("marks_mastervalue",$value);

//	ref_id - 
			$value="";
				$value=DisplayLookupWizard("ref_id",$data["ref_id"],$data,$keylink,MODE_PRINT);
			$xt->assign("ref_id_mastervalue",$value);

//	buyer_address - 
			$value="";
				$value = ProcessLargeText(GetData($data,"buyer_address", ""),"field=buyer%5Faddress".$keylink,"",MODE_PRINT);
			$xt->assign("buyer_address_mastervalue",$value);

//	consignee_address - 
			$value="";
				$value = ProcessLargeText(GetData($data,"consignee_address", ""),"field=consignee%5Faddress".$keylink,"",MODE_PRINT);
			$xt->assign("consignee_address_mastervalue",$value);
	$xt->display("packing_lists_masterprint.htm");
	$strTableName=$oldTableName;

}

?>